package service.impl;

import dao.PraiseDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import service.PraiseService;
import vo.PraiseVo;

@Service
public class PraiseServiceImpl implements PraiseService {

    @Autowired
    PraiseDao praiseDao;


    //点赞
    @Override
    public boolean tgPraise(PraiseVo praiseVo) {
        Integer commentid=praiseVo.getComment_id();
        Integer userid=praiseVo.getUser_id();
        boolean b;
        //赞前查询是否点赞过
        int i = praiseDao.queryPraisedByCommentidAndUserid(userid,commentid);
        if (i==0) {
            praiseDao.addCommentPraiseById(praiseVo);
            b=true;
        } else {
            praiseDao.removeCommentPraiseById(userid,commentid);
            b=false;
        }
        return b;
    }
}
